package com.qf.springmvc02.util;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * @author nk
 * @date 2022/5/5 9:16
 */
public class SalarySerialize implements ObjectSerializer {
    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        //object 就是需要序列化属性的值   fieldName 需要序列化属性的名字  fieldType 属性的类型
        Double salary = (Double) object;
        String text = salary+"元";
        serializer.write(text);
    }
}
